-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config inheritance for personality field #169
Conversation
c569149
to
1c40da3
Compare
for value in self._get_attr_values(attr): | ||
path = os.path.join(dir_path, attr, value + '.ini') | ||
namespace = dir_ns + '_'.join((attr, value)) | ||
config_files.append((path, namespace)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be a much nicer version of my idea for the last time this came up. See 3b3414c.
I'm all for this and make a quick attempt at this a while back that I never finished. |
It turns out the hard parts are:
|
Yeah, that is probably very annoying. I don't envy you...
It is deliberate. Hmm, I think I have a solution for the sorted merge... |
See #170. |
It is often the case that we want to build an image which just applies a few minor changes to an existing personality. For instance, the apps we want for most Spanish images are the same, but we have a few country-specific applications, and we often wish to build a sub-variant for a partner or region of a particular country. Currently we need to copy the full list of apps & settings from our es.ini personality config into (for instance) es_MX.ini; and then again from es_MX.ini into (e.g.) es_MX_aguascalientes.ini to add some region-specific apps or resources Implement a form of inheritance where (e.g.) building the es_MX personality reads es.ini and es_MX.ini, in that order; and (e.g.) building the es_MX_aguascalientes personality reads es.ini, es_MX.ini and es_MX_aguascalientes.ini, again in that order. This matches the convention that we have of naming personalities for the locale, and then adding further underscore-separated suffixes for subvariants thereof. This is only implemented for the personality field. This is where we do most of our customisation and is the place where inheritance would be most useful. https://phabricator.endlessm.com/T34731
Now that we have inheritance in personality configs, it becomes useful to be able to say that (for example) es_MX should add 1 specific channel to the selection inherited from es. Since commit 59980bc, values in merged fields keep the order in which they were first encountered. As a result, if (for example) the es personality specifies channels B, D, C (in that order) and es_MX adds channel A, then the resulting order is B, D, C, A. The order is significant: it is the order that channels are shown in the Kolibri Learn tab. So in this case it is not possible to move channel A to the top of the list without overriding the whole list of channels (which is possible but loses the benefit of this change). In practice, I only found two cases where this happens; in one case I hardcoded the previous order, and in the other case I just accepted the slight change. https://phabricator.endlessm.com/T34731
For projects in Haiti we have a (private) fr_HT personality. Checking our metrics, the majority of fr activations are in metropolitan France (the hexagonal bit of France that is just across the channel from the UK, rather than overseas regions).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a winner!
ini_name = (value1 + '-' + value2 + '.ini') | ||
path = os.path.join(dir_path, attr1 + '-' + attr2, ini_name) | ||
namespace = (dir_ns + | ||
'_'.join((attr1, attr2, value1, value2))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, string joins with +
. Older Dan is ashamed of younger Dan.
It is often the case that we want to build an image which just applies a
few minor changes to an existing personality. For instance, the apps we
want for most Spanish images are the same, but we have a few
country-specific applications, and we often wish to build a sub-variant
for a partner or region of a particular country.
Currently we need to copy the full list of apps & settings from our
es.ini personality config into (for instance) es_MX.ini; and then again
from es_MX.ini into (e.g.) es_MX_aguascalientes.ini to add some
region-specific apps or resources
Implement a form of inheritance where (e.g.) building the es_MX
personality reads es.ini and es_MX.ini, in that order; and (e.g.)
building the es_MX_aguascalientes personality reads es.ini, es_MX.ini
and es_MX_aguascalientes.ini, again in that order. This matches the
convention that we have of naming personalities for the locale, and then
adding further underscore-separated suffixes for subvariants thereof.
This is only implemented for the personality field. This is where we do
most of our customisation and is the place where inheritance would be
most useful.
https://phabricator.endlessm.com/T34731